package com.sanyang.lawyer.mapper.Case;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sanyang.lawyer.ResultApi.ResponseResult;
import com.sanyang.lawyer.entity.Case_audit;
import com.sanyang.lawyer.entity.Case_law;
import com.sanyang.lawyer.entity.Case_message;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;


public interface Case_lawMapper extends BaseMapper<Case_law> {
    
    //模糊查询所有
    public List<Case_law> selectLikeList(Case_law case_law);
    
    //根据id查询单条
    public Case_law queryOne(String caseId);
    
    //利益冲突监测
    public List<Case_law> detection(Case_message case_message);

    //查询全部 不含模糊查询
    public List<Case_law> listall();
    //查询全部包含模糊查询
    public List<Case_law> listalls(Map<String,String> map);

    public List<Case_law> getlist();

    //6种模糊查询
    public List<Case_law> casequery(Map<String,String> map);

    //查询审批中数量
    public List<Case_law> backlog();
    public List<Case_law> backlogl();
    public List<Case_law> settle();

    //查询最大的version
    @Select("select MAX(version) from case_law")
    @ResultType(Integer.class)
    public int getMaxKey();

    //添加一条案件
    public void insertOne(Case_law case_law);

    //根据流程id查询出相关的案件信息
    public Case_law queryCaseByprocessid(String processid);
    
    
    
    //修改案件审核状态
    @Update("update case_law set close_state= #{closeState}," +
            "close_mode = #{closeMode}," +
            "close_date=#{closeDate}")
    public void update_closestate(Case_law case_law);

    //根据案件id查询案号,委托人名称，代理费用，杂费
    public Case_law gatheringQuery(String caseid);


    //修改数据库中的数据  修改未付（case_unpaidsal）,实付（reality_money）.
    @Update("update case_law set case_unpaidsal=case_unpaidsal-#{amountMoney} ," +
            "reality_money = reality_money+#{amountMoney}")
    public void gathering(Case_law law);


    //费用减免修改 代理费 应付 和未付  减去 减免费用
    @Update("update case_law set amount_money=amount_money-#{remissionMoney} ," +
            " case_unpaidsal = case_unpaidsal - #{remissionMoney} ," +
            " agency_money = agency_money-#{remissionMoney}" +
            " where case_id = #{caseid.caseId}")
    public void complateUpdte(Case_audit case_audit);

    
    //根据审核id查询案件id
    @Select("select a.case_id from case_law a, audit b, case_audit c " +
            "where a.case_id = c.caseid" +
            " and b.auditid = c.auditid" +
            " and b.auditid = #{processid}")
    public String queryCaseidByProcessid(String processid);
    
    
    //根据案件id修改案件的状态
    @Update("update case_law set case_status='已结案' where case_id = #{caseid}")
    public void updateCase_status(String caseid);

    //案件修改
    public void Case_update(Case_law law);


    //查询出所有的案件状态为已删除的
    public List<Case_law> selectCaseBystatus(com.sanyang.lawyer.entity.Case_law case_law);

    //根据案件id将案件表的状态修改为已删除
    @Update("update case_law set case_status = '已删除' where case_id = #{caseid}")
    public void deleteCase(String caseid);
    
    

    //收结案统计
    public List<Map<String,Object>> StatisticsList(Map map);
    public Integer StatisticsListCount(Map map);
    //业务收费汇总
    public List<Map<String,Object>> businessCharge(Map map);
    public Integer businessChargeCount(Map map);
    //个人业务总计
    public List<Map<String,Object>> personalBusiness(Map map);
    public Integer personalBusinessCount(Map map);
    //法律顾问汇总
    public List<Map<String,Object>> legalCounsel(Map map);
    public Integer legalCounselCount(Map map);
    
}
